package com.biz.primus.model.member.vo.request;

import com.biz.primus.base.global.GlobalValue;
import com.biz.primus.base.global.Ref;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.data.domain.PageRequest;

/**
 * @author jun.liu
 * @date 2017年10月22日
 * @reviewer
 * @see
 */
@ApiModel(description = "vo")
@Getter
@Setter
@ToString
public class NoticePageRequestVo extends BaseRequestVo
{

    private static final long serialVersionUID = 2736159296193555264L;

	@ApiModelProperty(value = "用户ID", required = true)
	@Ref(GlobalValue.memberId)
	private Long userId;

	@ApiModelProperty("分页参数:要加载的页面,第一页为1,不传时默认值为1")
	private int page = 1;

	@ApiModelProperty("分页参数:每页记录数,不传时默认值为50")
	private int size = 50;

	public PageRequest toPageRequest() {
		page = Math.max(page, 1);
		return new PageRequest(page - 1, size);
	}

}
